<template>
  <div class="body">
    <!-- 标题 -->
    <v-nation></v-nation>
    <!-- 导航栏 -->
    <!-- 高级检索 -->
    <Row class="restand">
        <i-col class="standkepu" span="17">
          <div class="standardt">
                请输入检索条件
          </div>
          <div class="condition">
              <Row class="searchcondition">
                  <!-- <i-col span="12">
                    <span class="conditioninputitle">关键字</span>
                    <Input v-model="keyword" placeholder="请输入关键字" class="conditioninpu" />
                  </i-col> -->
                  <i-col span="12">
                    <span class="conditioninputitle">标准号</span>
                    <Input v-model="ssnum" placeholder="请输入标准号" class="conditioninpu" />
                  </i-col>
                  <i-col span="12">
                    <span class="conditioninputitle">英文名称</span>
                    <Input v-model="sen" placeholder="请输入英文名称" class="conditioninpu" />
                  </i-col>
              </Row>
              <Row class="searchcondition">
                  <i-col span="12">
                    <span class="conditioninputitle">中文名称</span>
                    <Input v-model="scn" placeholder="请输入中文名称" class="conditioninpu" />
                  </i-col>
                  <i-col span="12">
                    <span class="conditioninputitle">中国标准分类号(CCS)</span>
                    <Input v-model="ccs" placeholder="" class="conditioninpuss" />
                    <i-button type="info" @click="modal2 = true">选择</i-button>
                  </i-col>
              </Row>
              <Row class="searchcondition">
                  <i-col span="12">
                    <span class="conditioninputitle">国际标准分类号(ICS)</span>
                    <Input v-model="ics" placeholder="" class="conditioninpuss" />
                    <Button type="info" @click="modal1 = true">选择</Button>
                  </i-col>
                  <i-col span="12">
                    <span class="conditioninputitle">起草单位</span>
                    <Input v-model="sdfu" placeholder="请输入起草单位" class="conditioninpu" />
                  </i-col>
              </Row>
              <!-- <Row class="searchcondition">
                  <i-col span="12">
                    <span class="conditioninputitle">发布日期</span>
                    <Date-picker format="yyyy-MM-dd" @on-change="time1" type="date" :value="sisd" class="conditioninpu" placeholder="选择日期" ></Date-picker>
                  </i-col>
                  <i-col span="12">
                    <span class="conditioninputitle">实施日期</span>
                    <Date-picker format="yyyy-MM-dd" @on-change="time2" type="date" :value="sefd" class="conditioninpu" placeholder="选择日期" ></Date-picker>
                  </i-col>
              </Row> -->
              <Row class="searchcondition">
                  <i-col span="12">
                    <span class="conditioninputitle">标准组织</span>
                    <span class="localorgnum">国家标准</span>
                  </i-col>
                  <i-col span="12">
                    <!-- <span class="conditioninputitle">年代号</span>
                    <DatePicker type="year" @on-change="handleChange" v-model="agenumber" format="yyyy" placeholder="选择年代" class="conditioninpu"></DatePicker> -->
                    <span class="conditioninputitle">起草人</span>
                    <Input v-model="sdfp" placeholder="请输入起草人" class="conditioninpu" />
                  </i-col>
              </Row>
              <Row class="searchcondition">
                  <i-col span="12">
                    <span class="conditioninputitle">标准状态</span>
                    <RadioGroup v-model="sstatus" class="conditioninpu" type="button">
                        <Radio label="现行"></Radio>
                        <Radio label="未生效"></Radio>
                        <Radio label="废止"></Radio>
                        <Radio label="作废"></Radio>
                    </RadioGroup>
                  </i-col>

              </Row>
              <!-- <Row class="searchcondition">
                  <i-col span="12">
                    <span class="conditioninputitle">标准分类</span>
                    <RadioGroup v-model="sfenlei" class="conditioninpu" type="button">
                        <Radio label="G"><span>国标</span></Radio>
                        <Radio label="D"><span>地标</span></Radio>
                        <Radio label="C"><span>行标</span></Radio>
                    </RadioGroup>
                  </i-col>
              </Row> -->
              <br>
              <Button class="searchbutton" type="success" v-on:click="getSearch()">检索(Search)</Button>
              <Button class="resetbutton" type="success" >重置(Reset)</Button>
          </div>
          <div class="result">
            <div class="resultitem" v-for="(item,index) in results" :key="index">
              <div @click="getDetail(item.Id)" class="itemtitle"><span v-html="item.StandNum"></span>&#12288;&#12288;{{ item.Cn }}
                <Tag checkable color="success" class="stalstatus" v-if="item.StandStatus==='现行'">{{item.StandStatus}}</Tag>
                <Tag checkable color="error" class="stalstatus" v-else-if="item.StandStatus==='废止'">{{item.StandStatus}}</Tag>
                <Tag checkable color="warning" class="stalstatus" v-else-if="item.StandStatus==='未生效'">{{item.StandStatus}}</Tag>
                <Tag checkable color="default" class="stalstatus" v-else-if="item.StandStatus==='作废'">{{item.StandStatus}}</Tag>
              </div>
              <div class="itemics"><Icon type="ios-appstore" /><span class="itemicss">国际标准分类号（ICS）{{ item.ICS }}</span>&#12288;&#12288;<Icon type="ios-aperture" /><span class="itemcsss">中国标准分类号（CCS）{{ item.CCS }}</span></div>
              <div class="itemdetail">英文标题&#12288;&#12288;{{ item.En }}</div>
              <div class="itemdetail">起草单位&#12288;&#12288;<span v-html="item.DraftingUnit"></span></div>
              <div class="itemdetail">起草人&#12288;&#12288;<span v-html="item.DraftingPeople"></span></div>
              <div class="itemtime"><Icon color="#428bca" size="20" type="ios-cloud-upload" /><span class="itemtimefabu">发布于&#8194;{{ item.Isd }}</span><Icon color="#3c763d" size="20" type="md-checkbox" /><span class="itemtimeshishi">实施于&#8194;{{ item.Efd }}</span></div>
            </div>
             <Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepage" v-if="showPage" class-name="changepage" show-elevator />
          </div>
        </i-col>
    </Row>
      <Modal
        v-model="modal1"
        title="ICS"
        width='550px'
        @on-ok="ok1"
        @on-cancel="cancel1">
        <CheckboxGroup v-model="ics">
          <span class="icsitem" v-for="item in icsarry" :key="item">
            <Checkbox :label="item.Code"><span>{{item.Name}}</span></Checkbox>
          </span>
        </CheckboxGroup>
      </Modal>
      <Modal
        v-model="modal2"
        title="CCS"
        width='550px'
        @on-ok="ok2"
        @on-cancel="cancel2">
        <CheckboxGroup v-model="ccs">
          <span class="icsitem" v-for="item in ccsarry" :key="item" >
            <Checkbox :label="item.Code"><span>{{item.Name}}</span></Checkbox>
          </span>
        </CheckboxGroup>
      </Modal>
      <Modal
        v-model="modal3"
        title="标准组织选择"
        width='770px'
        @on-ok="ok3"
        @on-cancel="cancel3">
        <Select v-model="orgn" filterable multiple class="conditioninpuorg">
            <Option v-for="item in orgarry" :value="item.OraganizationCode" :key="item.OraganizationCode">{{ item.OraganizationName }}</Option>
        </Select>
      </Modal>
    <!-- 底部 -->
    <v-foot></v-foot>
    <Back-top></Back-top>
  </div>
</template>
<script>
import {neturl} from '../assets/js/common'
export default {
  name: 'seniorsearch',
  data () {
    return {
      msg: '内蒙古标准文献服务平台',
      theme1: 'light',
      byname: 'bymenu',
      value: '',
      results: [],
      modal1: false,
      modal2: false,
      modal3: false,
      keyword: '',
      dataCount: 0,
      pageSize: 10,
      pageNum: 1,
      showPage: false,
      islogin: false,
      islog: true,
      username: '',
      userinfo: '',
      cnname: '',
      scn: '',
      sen: '',
      sics: '',
      sccs: '',
      sisd: '',
      sefd: '',
      sstatus: '',
      button2: '',
      sfenlei: '',
      ssnum: '',
      sdfu: '',
      sdfp: '',
      ics: [],
      ccs: [],
      orgn: 'GB',
      org: '',
      sorgnum: '',
      icsarry: [],
      ccsarry: [],
      orgarry: [],
      agenumber: ''
    }
  },
  methods: {
    handleChange (year) {
      this.agenumber = year
    },
    ok1 () {
    },
    cancel1 () {
    },
    ok2 () {
    },
    cancel2 () {
    },
    ok3 () {
    },
    cancel3 () {
    },
    time1 (e) {
      this.sisd = e
    },
    time2 (e) {
      this.sefd = e
    },
    getics () {
      this.$axios.post(neturl + '/by/category/getics'
      ).then(res => {
        this.icsarry = res.data.data.result
      })
    },
    getccs () {
      this.$axios.post(neturl + '/by/category/getccs'
      ).then(res => {
        this.ccsarry = res.data.data.result
      })
    },
    // getorgnum () {
    //   this.$axios.post(neturl + '/by/category/getorgnum'
    //   ).then(res => {
    //     this.orgarry = res.data.data.result
    //   })
    // },
    getSearchResult () {
      this.$Spin.show()
      let upload = { data: '{keyword: ' + "'" + this.keyword + ',DB15' + "'" + ', page: ' + this.pageNum + ', pagesize: ' + this.pageSize + '}' }
      this.$axios.post(neturl + '/by/search/ys', upload
      ).then(res => {
        this.$Spin.hide()
        // console.log(res)
        this.results = res.data.data.rows
        this.dataCount = res.data.data.total
        this.showPage = true
      })
    },
    getSearch () {
      if (this.keyword === '' || this.keyword === undefined) {
        // 关键字为空
        this.getAdvancedSearch()
      } else {
        this.getSearchResult()
      }
    },
    getAdvancedSearch () {
      this.keyword = ''
      this.$Spin.show()
      let upload = { data: '{ssnum: ' + "'" + this.ssnum + "'" +
       ', scn: ' + "'" + this.scn + "'" +
       ', sen: ' + "'" + this.sen + "'" +
       ', sics: ' + "'" + this.ics + "'" +
       ', sccs: ' + "'" + this.ccs + "'" +
       ', sstatus: ' + "'" + this.sstatus + "'" +
       ', orgn: ' + "'" + this.orgn + "'" +
       ', agenumber: ' + "'" + this.agenumber + "'" +
       ', sfenlei: ' + "'" + this.sfenlei + "'" +
       ', sisd: ' + "'" + this.sisd + "'" +
       ', sefd: ' + "'" + this.sefd + "'" +
       ', sdfu: ' + "'" + this.sdfu + "'" +
       ', sdfp: ' + "'" + this.sdfp + "'" +
       ', page: ' + this.pageNum +
       ', pagesize: ' + this.pageSize +
       '}' }
      // console.log(upload)
      this.$axios.post(neturl + '/by/search/gs', upload
      ).then(res => {
        this.$Spin.hide()
        // console.log(res)
        this.results = res.data.data.rows
        this.dataCount = res.data.data.total
        this.showPage = true
      })
    },
    changepage (value) {
      this.pageNum = value
      if (this.keyword === '' || this.keyword === undefined) {
        this.getAdvancedSearch()
      } else {
        this.getSearchResult()
      }
    },
    getDetail (id) {
      let routeData = this.$router.resolve({path: '/standdetail', query: {id: id, keyword: this.keyword}})
      window.open(routeData.href, '_self')
    },
    logout () {
      this.$cookie.delete('user')
      let routeUrl = this.$router.resolve({
        path: '/'
      })
      window.open(routeUrl.href)
    }
  },
  created () {
    this.userinfo = this.$cookie.get('user')
    this.userinfo = JSON.parse(this.userinfo)
    // 已登录
    if (this.userinfo != null) {
      this.islogin = true
      this.islog = false
      this.username = this.userinfo.realName
    }
    this.keyword = this.$route.query.keyword
    if (this.keyword !== '' && this.keyword !== undefined) {
      this.getSearchResult()
    }
    // 获取ics分类
    this.getics()
    // 获取ccs分类
    this.getccs()
    // 获取标准组织分类
    // this.getorgnum()
  }
}
</script>

<style scoped>
  @import '../assets/css/localstand.css';
</style>
